package File;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Arrays;

public class test {
    public static void main(String[] args) {
        searchFile(new File("D:/"), "QQ.exe");
    }

    public static void searchFile(File dir, String fileName){
        // 判断dir是否合法
        if(dir == null || !dir.exists() || dir.isFile())
            return;

        File[] files = dir.listFiles();

        if(files != null && files.length > 0){
            for (File file : files) {
                if(file.isFile() && file.getName().contains(fileName)){
                        System.out.println(file.getAbsolutePath());
                } else {
                    searchFile(file, fileName);
                }
            }
        }
    }
}
